package com.itheima.zhuanhuan;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/*
编解码
 */
public class Demo03 {

    public static void main(String[] args) throws UnsupportedEncodingException {
        String s="我爱中国";
        byte[] bytes = s.getBytes();//使用默认编码方式 utf-8
        System.out.println(Arrays.toString(bytes));
        // new String(bytes)  解码 将 字节->字符  使用默认 编码方式 utf-8
        System.out.println(new String(new byte[]{-26, -120, -111}));
        System.out.println(new String(new byte[]{-25, -120, -79}));
        System.out.println(new String(new byte[]{-28, -72, -83}));
        System.out.println(new String(new byte[]{-27, -101, -67}));
        byte[] gbks = s.getBytes("GBK");//使用gbk 编码
        System.out.println(Arrays.toString(gbks));
        String s1 = new String(new byte[]{-50, -46, -80, -82, -42, -48, -71, -6},"GBK");
        System.out.println(s1);


    }
}
